package com.ly.sy;

import com.ly.sy.entity.Comment;
import com.ly.sy.service.CommentService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;
import java.util.*;

public class test {

    public static void main(String[] args) {

        int arr[] = {10,30,24,100,79,98,11,1};
        //1,30,24,100,79,98,11,10
        //1,24,30,...10
        //1,11,30,100,79,98,24,10
        //1,10,30,...11
        //1,10,24,100,79,98,30,11
        //1,10,11,100,79,98,30,11
        //选择排序
        for(int j=0; j<arr.length-1; j++){
            for(int i=0; i<arr.length-1; i++){
                if (arr[j]>arr[i]) {
                    int b=arr[j];
                    arr[j]=arr[i];
                    arr[i]=b;
                    if(i==arr.length-1) break;
                }
            }

        }



        //冒泡排序
//        boolean z = true;
//        for(int j=0; j<arr.length; j++){
//            for(int i=0; i<arr.length-1; i++){
//                int a = arr[i];
//                int b = arr[i+1];
//                if(a>b){
//                    arr[i]=arr[i+1];
//                    arr[i+1]=a;
//                    z =false;
//                }
//            }
//            if (z){
//                break;
//            }
//        }
        System.out.println(Arrays.toString(arr));

    }

}
